from research.calcor import calcor_base
class AVG_byargs:
    def oncalc(self,*d,timekey=None):
        for i in d:
            if i is None:
                return None
        return sum(d)/len(d)

class AVG_bymatrix(calcor_base):
    def __init__(self,timeperiod=10):
        super().__init__(timeperiod=timeperiod,datatype="dimn")
    def calc(self):
        ss=[]
        lens=[]
        for i in self.hisdata:
            ss.append(sum(i))
            lens.append(len(i))
        total=sum(lens)
        avg=sum(ss)/total
        return avg